package com.cheng.quartz;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.cheng.service.takedelivery.PromotionService;
import com.cheng.service.takedelivery.WayBillService;

@Component
public class PromotionJob /*传统定时框架执行任务实现该接口implements Job*/ {

	@Autowired
	private PromotionService promotionService;
	@Autowired
	private WayBillService wayBillService;
	
	//传统定时框架执行任务
	/*@Override
	public void execute(JobExecutionContext context)
			throws JobExecutionException {
		promotionService.updatePromotion(new Date());
		
	}*/
	
	@Scheduled(cron = "0 0 0-23 * * ? ")
	public void execute(){
		promotionService.updatePromotion(new Date());
	}

	 @Scheduled(cron = "0 0 0-23 * * ? ")
	 public void syncIndex(){
		 System.out.println("同步索引库");
		 wayBillService.syncIndex();
	 }
}
